﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;

using CNCSoft.EWinform;
using CNCSoft.EWinform.ControlUtils;
using CNCSoft.EWinform.ERPApps;
using CNCSoft.EWinform.AGrid;
using CNCSoft.EData;

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using Common;

namespace CNCSoft.ErpApps.TMS {

	/// <summary>
	/// Summary description for TienMatPhieuThuHocphi.
	/// </summary>
    public class TienMatPhieuThuLe : System.Windows.Forms.Form
    {
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label8;
        private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		internal System.Windows.Forms.Panel pnlButtons;
		internal System.Windows.Forms.Button cmdModify;
		internal System.Windows.Forms.Button cmdCancel;
		internal System.Windows.Forms.Button cmdPrint;
		internal System.Windows.Forms.Button cmdView;
		internal System.Windows.Forms.Button cmdDelete;
		internal System.Windows.Forms.Button cmdAddNew;
		private System.Windows.Forms.PictureBox pictureBox2;
        private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.TextBox txtHoTenNguoiNopTien;
        private System.Windows.Forms.TextBox txtDienGiai;
		private System.Windows.Forms.TextBox txtSoChungTu;
        private System.Windows.Forms.ComboBox cboLyDoThu;
		private System.Windows.Forms.Button cmdXemTK;
		internal System.Windows.Forms.Button cmdUpdate;
		private System.Windows.Forms.TextBox txtDiaChi;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ToolTip toolTip1;
		private System.Windows.Forms.ErrorProvider ep;
        private System.Windows.Forms.Label lblStatus;
		private System.Windows.Forms.Panel pnlNevigator;
		internal System.Windows.Forms.Button cmdMovePrevious;
		internal System.Windows.Forms.Button cmdMoveFirst;
		internal System.Windows.Forms.Button cmdMoveLast;
		internal System.Windows.Forms.Button cmdMoveNext;
        private CNCSoft.EWinform.ValidText txtNgayChungTu;
		private System.Windows.Forms.Label lblRecordInfo;
		private System.Windows.Forms.Panel pnlBottom;
		private System.Windows.Forms.PictureBox picboxNote;
        private System.Windows.Forms.PictureBox picboxHelp;
        private TextBox txtSoHoaDon;
        private Label label16;
        private ValidText txtNgayHoaDon;
        private Label label18;
        private TextBox txtSerialHoaDon;
        private Label label17;
        private ListBox lstAddnew;
        private ComboBox cboNganHang;
        private Label label4;
        private DevExpress.XtraEditors.GridLookUpEdit gridLookUpEdit_txtMaHocSinh;
        private DevExpress.XtraGrid.Views.Grid.GridView gridLookUpEdit_txtMaHocSinhView;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_MaDoiTac;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_TenDoiTac;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_Lop;
        private Label label12;
        private TextBox txtMaNienHoc;
        private Label label7;
        private ComboBox cboLop;
        private Panel panel1;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_CheDo;
        private DevExpress.XtraGrid.GridControl dgridChiTietPT;
        private DevExpress.XtraGrid.Views.Grid.GridView gridView2;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_TaiKhoanCo;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_TieuKhoanCo;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_DienGiai;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_SoLuong;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_DonGia;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_ThanhTien;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_TaiKhoanNo;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_TieuKhoanNo;
        private DevExpress.XtraEditors.Repository.RepositoryItemCalcEdit repositoryItemCalcEdit_SoLuong;
        private DevExpress.XtraEditors.Repository.RepositoryItemTextEdit repositoryItemTextEdit_So;
        private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemLookUpEdit_TaiKhoan;
        private TextBox txtMaCheDo;
        private DevExpress.XtraGrid.Columns.GridColumn gridColumn_SoTienMienGiam;
        private txtChonTuDanhMuc txtMaCoSo;
        private Label label5;
        private TextBox txtSoTienThucThu;
        private Label lblThucThu;
        private DevExpress.XtraEditors.Repository.RepositoryItemTextEdit repositoryItemTextEdit_NhapSoLuong;
        private Label label13;
        private TextBox txtMaHocPhi;
        private DevExpress.XtraEditors.Repository.RepositoryItemTextEdit repositoryItemTextEdit1;
        private TextBox txtSoDuThangNay;
        private Label label15;
        private TextBox txtSoDuThangTruoc;
        private Label label14;
        private TextBox txtSoTien;
        private Label label11;
		private System.ComponentModel.IContainer components;

		public TienMatPhieuThuLe()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TienMatPhieuThuLe));
            DevExpress.XtraGrid.StyleFormatCondition styleFormatCondition1 = new DevExpress.XtraGrid.StyleFormatCondition();
            this.gridColumn_CheDo = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemTextEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.txtHoTenNguoiNopTien = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txtDienGiai = new System.Windows.Forms.TextBox();
            this.label8 = new System.Windows.Forms.Label();
            this.txtSoChungTu = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.cboLyDoThu = new System.Windows.Forms.ComboBox();
            this.pnlButtons = new System.Windows.Forms.Panel();
            this.cmdModify = new System.Windows.Forms.Button();
            this.cmdCancel = new System.Windows.Forms.Button();
            this.cmdPrint = new System.Windows.Forms.Button();
            this.cmdView = new System.Windows.Forms.Button();
            this.cmdDelete = new System.Windows.Forms.Button();
            this.cmdAddNew = new System.Windows.Forms.Button();
            this.cmdUpdate = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.txtDiaChi = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.toolTip1 = new System.Windows.Forms.ToolTip();
            this.txtSoHoaDon = new System.Windows.Forms.TextBox();
            this.txtSerialHoaDon = new System.Windows.Forms.TextBox();
            this.cmdXemTK = new System.Windows.Forms.Button();
            this.picboxNote = new System.Windows.Forms.PictureBox();
            this.picboxHelp = new System.Windows.Forms.PictureBox();
            this.txtSoTienThucThu = new System.Windows.Forms.TextBox();
            this.txtMaHocPhi = new System.Windows.Forms.TextBox();
            this.txtSoDuThangNay = new System.Windows.Forms.TextBox();
            this.txtSoDuThangTruoc = new System.Windows.Forms.TextBox();
            this.txtSoTien = new System.Windows.Forms.TextBox();
            this.ep = new System.Windows.Forms.ErrorProvider();
            this.lblStatus = new System.Windows.Forms.Label();
            this.pnlBottom = new System.Windows.Forms.Panel();
            this.pnlNevigator = new System.Windows.Forms.Panel();
            this.cmdMoveFirst = new System.Windows.Forms.Button();
            this.cmdMovePrevious = new System.Windows.Forms.Button();
            this.cmdMoveNext = new System.Windows.Forms.Button();
            this.cmdMoveLast = new System.Windows.Forms.Button();
            this.lblRecordInfo = new System.Windows.Forms.Label();
            this.txtNgayChungTu = new CNCSoft.EWinform.ValidText();
            this.label16 = new System.Windows.Forms.Label();
            this.label17 = new System.Windows.Forms.Label();
            this.txtNgayHoaDon = new CNCSoft.EWinform.ValidText();
            this.label18 = new System.Windows.Forms.Label();
            this.lstAddnew = new System.Windows.Forms.ListBox();
            this.label4 = new System.Windows.Forms.Label();
            this.cboNganHang = new System.Windows.Forms.ComboBox();
            this.gridLookUpEdit_txtMaHocSinh = new DevExpress.XtraEditors.GridLookUpEdit();
            this.gridLookUpEdit_txtMaHocSinhView = new DevExpress.XtraGrid.Views.Grid.GridView();
            this.gridColumn_MaDoiTac = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_TenDoiTac = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_Lop = new DevExpress.XtraGrid.Columns.GridColumn();
            this.txtMaNienHoc = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label12 = new System.Windows.Forms.Label();
            this.cboLop = new System.Windows.Forms.ComboBox();
            this.pictureBox2 = new System.Windows.Forms.PictureBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.dgridChiTietPT = new DevExpress.XtraGrid.GridControl();
            this.gridView2 = new DevExpress.XtraGrid.Views.Grid.GridView();
            this.gridColumn_TaiKhoanCo = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemLookUpEdit_TaiKhoan = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
            this.gridColumn_TieuKhoanCo = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_DienGiai = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_SoLuong = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemTextEdit_NhapSoLuong = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
            this.gridColumn_DonGia = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemTextEdit_So = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
            this.gridColumn_ThanhTien = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_SoTienMienGiam = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_TaiKhoanNo = new DevExpress.XtraGrid.Columns.GridColumn();
            this.gridColumn_TieuKhoanNo = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemCalcEdit_SoLuong = new DevExpress.XtraEditors.Repository.RepositoryItemCalcEdit();
            this.txtMaCheDo = new System.Windows.Forms.TextBox();
            this.txtMaCoSo = new CNCSoft.ErpApps.TMS.txtChonTuDanhMuc();
            this.label5 = new System.Windows.Forms.Label();
            this.lblThucThu = new System.Windows.Forms.Label();
            this.label13 = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.label14 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit1)).BeginInit();
            this.pnlButtons.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.picboxNote)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.picboxHelp)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.ep)).BeginInit();
            this.pnlBottom.SuspendLayout();
            this.pnlNevigator.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.gridLookUpEdit_txtMaHocSinh.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridLookUpEdit_txtMaHocSinhView)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dgridChiTietPT)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridView2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemLookUpEdit_TaiKhoan)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit_NhapSoLuong)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit_So)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCalcEdit_SoLuong)).BeginInit();
            this.SuspendLayout();
            // 
            // gridColumn_CheDo
            // 
            this.gridColumn_CheDo.Caption = "CĐ";
            this.gridColumn_CheDo.FieldName = "MaCheDo";
            this.gridColumn_CheDo.Name = "gridColumn_CheDo";
            this.gridColumn_CheDo.Visible = true;
            this.gridColumn_CheDo.VisibleIndex = 2;
            // 
            // repositoryItemTextEdit1
            // 
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.DisplayFormat.FormatString = "N0";
            this.repositoryItemTextEdit1.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(24, 163);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(56, 16);
            this.label1.TabIndex = 7;
            this.label1.Text = "Học sinh";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(466, 163);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(91, 16);
            this.label2.TabIndex = 9;
            this.label2.Text = "Người nộp tiền";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // txtHoTenNguoiNopTien
            // 
            this.txtHoTenNguoiNopTien.Location = new System.Drawing.Point(568, 160);
            this.txtHoTenNguoiNopTien.MaxLength = 50;
            this.txtHoTenNguoiNopTien.Name = "txtHoTenNguoiNopTien";
            this.txtHoTenNguoiNopTien.Size = new System.Drawing.Size(138, 23);
            this.txtHoTenNguoiNopTien.TabIndex = 10;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(24, 322);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(57, 16);
            this.label3.TabIndex = 24;
            this.label3.Text = "Diễn giải";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // txtDienGiai
            // 
            this.txtDienGiai.Location = new System.Drawing.Point(153, 319);
            this.txtDienGiai.MaxLength = 1000;
            this.txtDienGiai.Name = "txtDienGiai";
            this.txtDienGiai.Size = new System.Drawing.Size(591, 23);
            this.txtDienGiai.TabIndex = 25;
            this.txtDienGiai.Tag = "<LyDoThu> của <TenDonVi>";
            // 
            // label8
            // 
            this.label8.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(319, 35);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(36, 16);
            this.label8.TabIndex = 4;
            this.label8.Text = "Ngày";
            this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // txtSoChungTu
            // 
            this.txtSoChungTu.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.txtSoChungTu.ForeColor = System.Drawing.Color.ForestGreen;
            this.txtSoChungTu.Location = new System.Drawing.Point(362, 6);
            this.txtSoChungTu.MaxLength = 15;
            this.txtSoChungTu.Name = "txtSoChungTu";
            this.txtSoChungTu.Size = new System.Drawing.Size(109, 23);
            this.txtSoChungTu.TabIndex = 3;
            this.txtSoChungTu.TabStop = false;
            this.txtSoChungTu.Text = "Số chứng từ";
            // 
            // label9
            // 
            this.label9.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(319, 10);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(23, 16);
            this.label9.TabIndex = 2;
            this.label9.Text = "Số";
            this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Location = new System.Drawing.Point(24, 227);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(60, 16);
            this.label10.TabIndex = 14;
            this.label10.Text = "Lý do thu";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // cboLyDoThu
            // 
            this.cboLyDoThu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cboLyDoThu.Location = new System.Drawing.Point(153, 223);
            this.cboLyDoThu.MaxDropDownItems = 15;
            this.cboLyDoThu.Name = "cboLyDoThu";
            this.cboLyDoThu.Size = new System.Drawing.Size(212, 24);
            this.cboLyDoThu.TabIndex = 15;
            this.cboLyDoThu.SelectedIndexChanged += new System.EventHandler(this.cboLyDoThu_SelectedIndexChanged);
            this.cboLyDoThu.Validated += new System.EventHandler(this.cboLyDoThu_Validated);
            // 
            // pnlButtons
            // 
            this.pnlButtons.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.pnlButtons.Controls.Add(this.cmdModify);
            this.pnlButtons.Controls.Add(this.cmdCancel);
            this.pnlButtons.Controls.Add(this.cmdPrint);
            this.pnlButtons.Controls.Add(this.cmdView);
            this.pnlButtons.Controls.Add(this.cmdDelete);
            this.pnlButtons.Controls.Add(this.cmdAddNew);
            this.pnlButtons.Controls.Add(this.cmdUpdate);
            this.pnlButtons.Location = new System.Drawing.Point(94, 448);
            this.pnlButtons.Name = "pnlButtons";
            this.pnlButtons.Size = new System.Drawing.Size(711, 36);
            this.pnlButtons.TabIndex = 0;
            // 
            // cmdModify
            // 
            this.cmdModify.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdModify.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdModify.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdModify.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdModify.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdModify.Image = ((System.Drawing.Image)(resources.GetObject("cmdModify.Image")));
            this.cmdModify.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdModify.Location = new System.Drawing.Point(399, 3);
            this.cmdModify.Name = "cmdModify";
            this.cmdModify.Size = new System.Drawing.Size(80, 30);
            this.cmdModify.TabIndex = 4;
            this.cmdModify.Text = "&Sửa";
            this.cmdModify.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.cmdModify.Click += new System.EventHandler(this.cmdModify_Click);
            // 
            // cmdCancel
            // 
            this.cmdCancel.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdCancel.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdCancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdCancel.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdCancel.Image = ((System.Drawing.Image)(resources.GetObject("cmdCancel.Image")));
            this.cmdCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdCancel.Location = new System.Drawing.Point(231, 3);
            this.cmdCancel.Name = "cmdCancel";
            this.cmdCancel.Size = new System.Drawing.Size(80, 30);
            this.cmdCancel.TabIndex = 2;
            this.cmdCancel.Text = "&Bỏ qua";
            this.cmdCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
            // 
            // cmdPrint
            // 
            this.cmdPrint.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdPrint.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdPrint.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdPrint.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdPrint.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdPrint.Image = ((System.Drawing.Image)(resources.GetObject("cmdPrint.Image")));
            this.cmdPrint.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdPrint.Location = new System.Drawing.Point(567, 3);
            this.cmdPrint.Name = "cmdPrint";
            this.cmdPrint.Size = new System.Drawing.Size(80, 30);
            this.cmdPrint.TabIndex = 6;
            this.cmdPrint.Text = "&In";
            this.cmdPrint.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.cmdPrint, "In phiếu thu");
            this.cmdPrint.Click += new System.EventHandler(this.cmdPrint_Click);
            // 
            // cmdView
            // 
            this.cmdView.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdView.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdView.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdView.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdView.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdView.Image = ((System.Drawing.Image)(resources.GetObject("cmdView.Image")));
            this.cmdView.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdView.Location = new System.Drawing.Point(315, 3);
            this.cmdView.Name = "cmdView";
            this.cmdView.Size = new System.Drawing.Size(80, 30);
            this.cmdView.TabIndex = 3;
            this.cmdView.Text = "&Phiếu cũ";
            this.cmdView.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.cmdView, "Xem, chọn lại phiếu cũ");
            this.cmdView.Click += new System.EventHandler(this.cmdView_Click);
            // 
            // cmdDelete
            // 
            this.cmdDelete.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdDelete.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdDelete.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdDelete.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdDelete.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdDelete.Image = ((System.Drawing.Image)(resources.GetObject("cmdDelete.Image")));
            this.cmdDelete.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdDelete.Location = new System.Drawing.Point(483, 3);
            this.cmdDelete.Name = "cmdDelete";
            this.cmdDelete.Size = new System.Drawing.Size(80, 30);
            this.cmdDelete.TabIndex = 5;
            this.cmdDelete.Text = "&Xoá";
            this.cmdDelete.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.cmdDelete, "Xóa phiếu thu hiện tại");
            this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click);
            // 
            // cmdAddNew
            // 
            this.cmdAddNew.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdAddNew.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdAddNew.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdAddNew.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdAddNew.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdAddNew.Image = ((System.Drawing.Image)(resources.GetObject("cmdAddNew.Image")));
            this.cmdAddNew.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdAddNew.Location = new System.Drawing.Point(63, 3);
            this.cmdAddNew.Name = "cmdAddNew";
            this.cmdAddNew.Size = new System.Drawing.Size(80, 30);
            this.cmdAddNew.TabIndex = 0;
            this.cmdAddNew.Text = "&Thêm";
            this.cmdAddNew.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.cmdAddNew, "Thêm phiếu thu mới");
            this.cmdAddNew.Click += new System.EventHandler(this.cmdAddNew_Click_1);
            // 
            // cmdUpdate
            // 
            this.cmdUpdate.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cmdUpdate.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdUpdate.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdUpdate.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdUpdate.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdUpdate.Image = ((System.Drawing.Image)(resources.GetObject("cmdUpdate.Image")));
            this.cmdUpdate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.cmdUpdate.Location = new System.Drawing.Point(147, 3);
            this.cmdUpdate.Name = "cmdUpdate";
            this.cmdUpdate.Size = new System.Drawing.Size(80, 30);
            this.cmdUpdate.TabIndex = 1;
            this.cmdUpdate.Text = "&Lưu";
            this.cmdUpdate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolTip1.SetToolTip(this.cmdUpdate, "Lưu phiếu thu này");
            this.cmdUpdate.Click += new System.EventHandler(this.cmdSave_Click);
            // 
            // groupBox1
            // 
            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBox1.Location = new System.Drawing.Point(1, 109);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(815, 8);
            this.groupBox1.TabIndex = 1;
            this.groupBox1.TabStop = false;
            // 
            // txtDiaChi
            // 
            this.txtDiaChi.Location = new System.Drawing.Point(153, 192);
            this.txtDiaChi.MaxLength = 500;
            this.txtDiaChi.Name = "txtDiaChi";
            this.txtDiaChi.Size = new System.Drawing.Size(591, 23);
            this.txtDiaChi.TabIndex = 13;
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(24, 195);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(47, 16);
            this.label6.TabIndex = 12;
            this.label6.Text = "Địa chỉ";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // txtSoHoaDon
            // 
            this.txtSoHoaDon.Location = new System.Drawing.Point(153, 350);
            this.txtSoHoaDon.MaxLength = 50;
            this.txtSoHoaDon.Name = "txtSoHoaDon";
            this.txtSoHoaDon.Size = new System.Drawing.Size(212, 23);
            this.txtSoHoaDon.TabIndex = 28;
            this.toolTip1.SetToolTip(this.txtSoHoaDon, "Đối với học viên, nhập vào đây số receipt");
            // 
            // txtSerialHoaDon
            // 
            this.txtSerialHoaDon.Location = new System.Drawing.Point(468, 350);
            this.txtSerialHoaDon.MaxLength = 50;
            this.txtSerialHoaDon.Name = "txtSerialHoaDon";
            this.txtSerialHoaDon.Size = new System.Drawing.Size(86, 23);
            this.txtSerialHoaDon.TabIndex = 30;
            this.toolTip1.SetToolTip(this.txtSerialHoaDon, "Đối với học viên, nhập vào đây số receipt");
            // 
            // cmdXemTK
            // 
            this.cmdXemTK.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdXemTK.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdXemTK.Font = new System.Drawing.Font("Tahoma", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdXemTK.ForeColor = System.Drawing.Color.DodgerBlue;
            this.cmdXemTK.Image = ((System.Drawing.Image)(resources.GetObject("cmdXemTK.Image")));
            this.cmdXemTK.Location = new System.Drawing.Point(753, 319);
            this.cmdXemTK.Name = "cmdXemTK";
            this.cmdXemTK.Size = new System.Drawing.Size(28, 22);
            this.cmdXemTK.TabIndex = 26;
            this.cmdXemTK.TabStop = false;
            this.toolTip1.SetToolTip(this.cmdXemTK, "Xem chi tiết tài khoản !.");
            this.cmdXemTK.Click += new System.EventHandler(this.cmdXemTK_Click);
            // 
            // picboxNote
            // 
            this.picboxNote.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.picboxNote.Cursor = System.Windows.Forms.Cursors.Hand;
            this.picboxNote.Image = ((System.Drawing.Image)(resources.GetObject("picboxNote.Image")));
            this.picboxNote.Location = new System.Drawing.Point(770, 8);
            this.picboxNote.Name = "picboxNote";
            this.picboxNote.Size = new System.Drawing.Size(20, 18);
            this.picboxNote.TabIndex = 384;
            this.picboxNote.TabStop = false;
            this.toolTip1.SetToolTip(this.picboxNote, "Ghi chú !.");
            this.picboxNote.Click += new System.EventHandler(this.cmdNote_Click);
            // 
            // picboxHelp
            // 
            this.picboxHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.picboxHelp.Cursor = System.Windows.Forms.Cursors.Hand;
            this.picboxHelp.Image = ((System.Drawing.Image)(resources.GetObject("picboxHelp.Image")));
            this.picboxHelp.Location = new System.Drawing.Point(794, 8);
            this.picboxHelp.Name = "picboxHelp";
            this.picboxHelp.Size = new System.Drawing.Size(20, 18);
            this.picboxHelp.TabIndex = 383;
            this.picboxHelp.TabStop = false;
            this.toolTip1.SetToolTip(this.picboxHelp, "Trợ giúp !.");
            this.picboxHelp.Click += new System.EventHandler(this.picboxHelp_Click);
            // 
            // txtSoTienThucThu
            // 
            this.txtSoTienThucThu.BackColor = System.Drawing.Color.White;
            this.txtSoTienThucThu.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtSoTienThucThu.ForeColor = System.Drawing.Color.IndianRed;
            this.txtSoTienThucThu.Location = new System.Drawing.Point(153, 287);
            this.txtSoTienThucThu.Name = "txtSoTienThucThu";
            this.txtSoTienThucThu.ReadOnly = true;
            this.txtSoTienThucThu.Size = new System.Drawing.Size(212, 23);
            this.txtSoTienThucThu.TabIndex = 21;
            this.txtSoTienThucThu.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.toolTip1.SetToolTip(this.txtSoTienThucThu, "Số tiền VND = Số tiền nguyên tệ x Tỉ giá");
            this.txtSoTienThucThu.Validated += new System.EventHandler(this.txtSoTienThucThu_Validated);
            // 
            // txtMaHocPhi
            // 
            this.txtMaHocPhi.Location = new System.Drawing.Point(470, 382);
            this.txtMaHocPhi.MaxLength = 50;
            this.txtMaHocPhi.Name = "txtMaHocPhi";
            this.txtMaHocPhi.Size = new System.Drawing.Size(84, 23);
            this.txtMaHocPhi.TabIndex = 36;
            this.txtMaHocPhi.TabStop = false;
            this.toolTip1.SetToolTip(this.txtMaHocPhi, "Đối với học viên, nhập vào đây số receipt");
            // 
            // txtSoDuThangNay
            // 
            this.txtSoDuThangNay.BackColor = System.Drawing.Color.White;
            this.txtSoDuThangNay.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtSoDuThangNay.ForeColor = System.Drawing.Color.IndianRed;
            this.txtSoDuThangNay.Location = new System.Drawing.Point(566, 290);
            this.txtSoDuThangNay.Name = "txtSoDuThangNay";
            this.txtSoDuThangNay.ReadOnly = true;
            this.txtSoDuThangNay.Size = new System.Drawing.Size(178, 23);
            this.txtSoDuThangNay.TabIndex = 23;
            this.txtSoDuThangNay.TabStop = false;
            this.txtSoDuThangNay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.toolTip1.SetToolTip(this.txtSoDuThangNay, "Số tiền VND = Số tiền nguyên tệ x Tỉ giá");
            // 
            // txtSoDuThangTruoc
            // 
            this.txtSoDuThangTruoc.BackColor = System.Drawing.Color.White;
            this.txtSoDuThangTruoc.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtSoDuThangTruoc.ForeColor = System.Drawing.Color.IndianRed;
            this.txtSoDuThangTruoc.Location = new System.Drawing.Point(566, 259);
            this.txtSoDuThangTruoc.Name = "txtSoDuThangTruoc";
            this.txtSoDuThangTruoc.Size = new System.Drawing.Size(178, 23);
            this.txtSoDuThangTruoc.TabIndex = 19;
            this.txtSoDuThangTruoc.TabStop = false;
            this.txtSoDuThangTruoc.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.toolTip1.SetToolTip(this.txtSoDuThangTruoc, "Số tiền VND = Số tiền nguyên tệ x Tỉ giá");
            this.txtSoDuThangTruoc.Validated += new System.EventHandler(this.txtSoDuThangTruoc_Validated);
            // 
            // txtSoTien
            // 
            this.txtSoTien.BackColor = System.Drawing.SystemColors.Info;
            this.txtSoTien.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtSoTien.ForeColor = System.Drawing.Color.IndianRed;
            this.txtSoTien.Location = new System.Drawing.Point(153, 258);
            this.txtSoTien.Name = "txtSoTien";
            this.txtSoTien.ReadOnly = true;
            this.txtSoTien.Size = new System.Drawing.Size(212, 23);
            this.txtSoTien.TabIndex = 17;
            this.txtSoTien.TabStop = false;
            this.txtSoTien.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.toolTip1.SetToolTip(this.txtSoTien, "Số tiền VND = Số tiền nguyên tệ x Tỉ giá");
            // 
            // ep
            // 
            this.ep.ContainerControl = this;
            this.ep.Icon = ((System.Drawing.Icon)(resources.GetObject("ep.Icon")));
            // 
            // lblStatus
            // 
            this.lblStatus.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblStatus.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.lblStatus.Location = new System.Drawing.Point(256, 6);
            this.lblStatus.Name = "lblStatus";
            this.lblStatus.Size = new System.Drawing.Size(461, 18);
            this.lblStatus.TabIndex = 341;
            this.lblStatus.Text = "Form đã khởi tạo thành công.";
            this.lblStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // pnlBottom
            // 
            this.pnlBottom.Controls.Add(this.picboxNote);
            this.pnlBottom.Controls.Add(this.picboxHelp);
            this.pnlBottom.Controls.Add(this.lblStatus);
            this.pnlBottom.Controls.Add(this.pnlNevigator);
            this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.pnlBottom.Location = new System.Drawing.Point(0, 500);
            this.pnlBottom.Name = "pnlBottom";
            this.pnlBottom.Size = new System.Drawing.Size(825, 28);
            this.pnlBottom.TabIndex = 7;
            // 
            // pnlNevigator
            // 
            this.pnlNevigator.Controls.Add(this.cmdMoveFirst);
            this.pnlNevigator.Controls.Add(this.cmdMovePrevious);
            this.pnlNevigator.Controls.Add(this.cmdMoveNext);
            this.pnlNevigator.Controls.Add(this.cmdMoveLast);
            this.pnlNevigator.Controls.Add(this.lblRecordInfo);
            this.pnlNevigator.Dock = System.Windows.Forms.DockStyle.Left;
            this.pnlNevigator.Location = new System.Drawing.Point(0, 0);
            this.pnlNevigator.Name = "pnlNevigator";
            this.pnlNevigator.Size = new System.Drawing.Size(241, 28);
            this.pnlNevigator.TabIndex = 343;
            // 
            // cmdMoveFirst
            // 
            this.cmdMoveFirst.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdMoveFirst.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdMoveFirst.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdMoveFirst.ForeColor = System.Drawing.Color.Maroon;
            this.cmdMoveFirst.Image = ((System.Drawing.Image)(resources.GetObject("cmdMoveFirst.Image")));
            this.cmdMoveFirst.Location = new System.Drawing.Point(19, 4);
            this.cmdMoveFirst.Name = "cmdMoveFirst";
            this.cmdMoveFirst.Size = new System.Drawing.Size(24, 20);
            this.cmdMoveFirst.TabIndex = 0;
            this.cmdMoveFirst.Click += new System.EventHandler(this.cmdMoveFirst_Click);
            // 
            // cmdMovePrevious
            // 
            this.cmdMovePrevious.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdMovePrevious.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdMovePrevious.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdMovePrevious.ForeColor = System.Drawing.Color.Maroon;
            this.cmdMovePrevious.Image = ((System.Drawing.Image)(resources.GetObject("cmdMovePrevious.Image")));
            this.cmdMovePrevious.Location = new System.Drawing.Point(47, 4);
            this.cmdMovePrevious.Name = "cmdMovePrevious";
            this.cmdMovePrevious.Size = new System.Drawing.Size(24, 20);
            this.cmdMovePrevious.TabIndex = 1;
            this.cmdMovePrevious.Click += new System.EventHandler(this.cmdMovePrevious_Click);
            // 
            // cmdMoveNext
            // 
            this.cmdMoveNext.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdMoveNext.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdMoveNext.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdMoveNext.ForeColor = System.Drawing.Color.Maroon;
            this.cmdMoveNext.Image = ((System.Drawing.Image)(resources.GetObject("cmdMoveNext.Image")));
            this.cmdMoveNext.Location = new System.Drawing.Point(79, 4);
            this.cmdMoveNext.Name = "cmdMoveNext";
            this.cmdMoveNext.Size = new System.Drawing.Size(24, 20);
            this.cmdMoveNext.TabIndex = 4;
            this.cmdMoveNext.Click += new System.EventHandler(this.cmdMoveNext_Click);
            // 
            // cmdMoveLast
            // 
            this.cmdMoveLast.Cursor = System.Windows.Forms.Cursors.Hand;
            this.cmdMoveLast.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cmdMoveLast.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmdMoveLast.ForeColor = System.Drawing.Color.Maroon;
            this.cmdMoveLast.Image = ((System.Drawing.Image)(resources.GetObject("cmdMoveLast.Image")));
            this.cmdMoveLast.Location = new System.Drawing.Point(107, 4);
            this.cmdMoveLast.Name = "cmdMoveLast";
            this.cmdMoveLast.Size = new System.Drawing.Size(24, 20);
            this.cmdMoveLast.TabIndex = 0;
            this.cmdMoveLast.Click += new System.EventHandler(this.cmdMoveLast_Click);
            // 
            // lblRecordInfo
            // 
            this.lblRecordInfo.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.lblRecordInfo.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblRecordInfo.Location = new System.Drawing.Point(135, 4);
            this.lblRecordInfo.Name = "lblRecordInfo";
            this.lblRecordInfo.Size = new System.Drawing.Size(96, 20);
            this.lblRecordInfo.TabIndex = 344;
            this.lblRecordInfo.Text = "Record Info";
            this.lblRecordInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // txtNgayChungTu
            // 
            this.txtNgayChungTu.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.txtNgayChungTu.ClearTime = false;
            this.txtNgayChungTu.DateDelimiter = "/";
            this.txtNgayChungTu.DateInputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayChungTu.DateOutputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayChungTu.FieldReference = null;
            this.txtNgayChungTu.Location = new System.Drawing.Point(362, 32);
            this.txtNgayChungTu.MaskEdit = "";
            this.txtNgayChungTu.MaxLength = 15;
            this.txtNgayChungTu.MessageLanguage = CNCSoft.EWinform.ValidText.MessageLanguages.Vietnamese;
            this.txtNgayChungTu.Name = "txtNgayChungTu";
            this.txtNgayChungTu.RegExPattern = CNCSoft.EWinform.ValidText.RegularExpressionModes.AutomatedDate;
            this.txtNgayChungTu.Required = false;
            this.txtNgayChungTu.ShowErrorIcon = true;
            this.txtNgayChungTu.Size = new System.Drawing.Size(109, 23);
            this.txtNgayChungTu.TabIndex = 5;
            this.txtNgayChungTu.ValidationMode = CNCSoft.EWinform.ValidText.ValidationModes.None;
            this.txtNgayChungTu.ValidText = "0123456789/ ";
            this.txtNgayChungTu.YearPrefix = ((short)(20));
            // 
            // label16
            // 
            this.label16.AutoSize = true;
            this.label16.Location = new System.Drawing.Point(23, 353);
            this.label16.Name = "label16";
            this.label16.Size = new System.Drawing.Size(72, 16);
            this.label16.TabIndex = 27;
            this.label16.Text = "Hóa đơn số";
            this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label17
            // 
            this.label17.AutoSize = true;
            this.label17.Location = new System.Drawing.Point(417, 353);
            this.label17.Name = "label17";
            this.label17.Size = new System.Drawing.Size(45, 16);
            this.label17.TabIndex = 29;
            this.label17.Text = "Serial ";
            this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // txtNgayHoaDon
            // 
            this.txtNgayHoaDon.ClearTime = false;
            this.txtNgayHoaDon.DateDelimiter = "/";
            this.txtNgayHoaDon.DateInputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayHoaDon.DateOutputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayHoaDon.FieldReference = null;
            this.txtNgayHoaDon.Location = new System.Drawing.Point(658, 350);
            this.txtNgayHoaDon.MaskEdit = "";
            this.txtNgayHoaDon.MaxLength = 15;
            this.txtNgayHoaDon.MessageLanguage = CNCSoft.EWinform.ValidText.MessageLanguages.Vietnamese;
            this.txtNgayHoaDon.Name = "txtNgayHoaDon";
            this.txtNgayHoaDon.RegExPattern = CNCSoft.EWinform.ValidText.RegularExpressionModes.AutomatedDate;
            this.txtNgayHoaDon.Required = false;
            this.txtNgayHoaDon.ShowErrorIcon = true;
            this.txtNgayHoaDon.Size = new System.Drawing.Size(86, 23);
            this.txtNgayHoaDon.TabIndex = 32;
            this.txtNgayHoaDon.ValidationMode = CNCSoft.EWinform.ValidText.ValidationModes.None;
            this.txtNgayHoaDon.ValidText = "0123456789/ ";
            this.txtNgayHoaDon.YearPrefix = ((short)(20));
            // 
            // label18
            // 
            this.label18.AutoSize = true;
            this.label18.Location = new System.Drawing.Point(604, 353);
            this.label18.Name = "label18";
            this.label18.Size = new System.Drawing.Size(36, 16);
            this.label18.TabIndex = 31;
            this.label18.Text = "Ngày";
            this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // lstAddnew
            // 
            this.lstAddnew.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.lstAddnew.BackColor = System.Drawing.SystemColors.Info;
            this.lstAddnew.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.lstAddnew.Cursor = System.Windows.Forms.Cursors.Hand;
            this.lstAddnew.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lstAddnew.FormattingEnabled = true;
            this.lstAddnew.ItemHeight = 18;
            this.lstAddnew.Location = new System.Drawing.Point(189, 404);
            this.lstAddnew.Name = "lstAddnew";
            this.lstAddnew.Size = new System.Drawing.Size(220, 54);
            this.lstAddnew.TabIndex = 1;
            this.lstAddnew.TabStop = false;
            this.lstAddnew.Visible = false;
            this.lstAddnew.SelectedIndexChanged += new System.EventHandler(this.lstAddnew_SelectedIndexChanged);
            this.lstAddnew.Leave += new System.EventHandler(this.lstAddnew_Leave);
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(24, 385);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(69, 16);
            this.label4.TabIndex = 33;
            this.label4.Text = "Ngân hàng";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // cboNganHang
            // 
            this.cboNganHang.Location = new System.Drawing.Point(153, 381);
            this.cboNganHang.MaxDropDownItems = 15;
            this.cboNganHang.Name = "cboNganHang";
            this.cboNganHang.Size = new System.Drawing.Size(213, 24);
            this.cboNganHang.TabIndex = 34;
            this.cboNganHang.SelectedIndexChanged += new System.EventHandler(this.cboNganHang_SelectedIndexChanged);
            // 
            // gridLookUpEdit_txtMaHocSinh
            // 
            this.gridLookUpEdit_txtMaHocSinh.Cursor = System.Windows.Forms.Cursors.Default;
            this.gridLookUpEdit_txtMaHocSinh.EditValue = " ";
            this.gridLookUpEdit_txtMaHocSinh.Location = new System.Drawing.Point(153, 159);
            this.gridLookUpEdit_txtMaHocSinh.Name = "gridLookUpEdit_txtMaHocSinh";
            this.gridLookUpEdit_txtMaHocSinh.Properties.Appearance.BackColor = System.Drawing.SystemColors.Info;
            this.gridLookUpEdit_txtMaHocSinh.Properties.Appearance.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
            this.gridLookUpEdit_txtMaHocSinh.Properties.Appearance.Options.UseBackColor = true;
            this.gridLookUpEdit_txtMaHocSinh.Properties.Appearance.Options.UseFont = true;
            this.gridLookUpEdit_txtMaHocSinh.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit;
            this.gridLookUpEdit_txtMaHocSinh.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.gridLookUpEdit_txtMaHocSinh.Properties.DisplayMember = "TenDoiTac";
            this.gridLookUpEdit_txtMaHocSinh.Properties.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Style3D;
            this.gridLookUpEdit_txtMaHocSinh.Properties.LookAndFeel.UseDefaultLookAndFeel = false;
            this.gridLookUpEdit_txtMaHocSinh.Properties.NullText = "<chọn học sinh>";
            this.gridLookUpEdit_txtMaHocSinh.Properties.NullValuePrompt = "<chọn học sinh>";
            this.gridLookUpEdit_txtMaHocSinh.Properties.PopupFilterMode = DevExpress.XtraEditors.PopupFilterMode.Contains;
            this.gridLookUpEdit_txtMaHocSinh.Properties.ValueMember = "MaDoiTac";
            this.gridLookUpEdit_txtMaHocSinh.Properties.View = this.gridLookUpEdit_txtMaHocSinhView;
            this.gridLookUpEdit_txtMaHocSinh.Size = new System.Drawing.Size(212, 25);
            this.gridLookUpEdit_txtMaHocSinh.TabIndex = 8;
            this.gridLookUpEdit_txtMaHocSinh.EditValueChanged += new System.EventHandler(this.gridLookUpEdit_txtMaHocSinh_EditValueChanged);
            this.gridLookUpEdit_txtMaHocSinh.Validated += new System.EventHandler(this.gridLookUpEdit_txtMaHocSinh_Validated);
            // 
            // gridLookUpEdit_txtMaHocSinhView
            // 
            this.gridLookUpEdit_txtMaHocSinhView.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
            this.gridColumn_MaDoiTac,
            this.gridColumn_TenDoiTac,
            this.gridColumn_Lop,
            this.gridColumn_CheDo});
            this.gridLookUpEdit_txtMaHocSinhView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
            styleFormatCondition1.Appearance.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128)))));
            styleFormatCondition1.Appearance.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
            styleFormatCondition1.Appearance.Options.UseBackColor = true;
            styleFormatCondition1.Column = this.gridColumn_CheDo;
            styleFormatCondition1.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal;
            styleFormatCondition1.Value1 = "\"NT\"";
            styleFormatCondition1.Value2 = "\"BA\"";
            this.gridLookUpEdit_txtMaHocSinhView.FormatConditions.AddRange(new DevExpress.XtraGrid.StyleFormatCondition[] {
            styleFormatCondition1});
            this.gridLookUpEdit_txtMaHocSinhView.Name = "gridLookUpEdit_txtMaHocSinhView";
            this.gridLookUpEdit_txtMaHocSinhView.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridLookUpEdit_txtMaHocSinhView.OptionsView.ShowAutoFilterRow = true;
            this.gridLookUpEdit_txtMaHocSinhView.OptionsView.ShowGroupPanel = false;
            // 
            // gridColumn_MaDoiTac
            // 
            this.gridColumn_MaDoiTac.Caption = "Mã HS";
            this.gridColumn_MaDoiTac.FieldName = "MaDoiTac";
            this.gridColumn_MaDoiTac.Name = "gridColumn_MaDoiTac";
            this.gridColumn_MaDoiTac.Width = 98;
            // 
            // gridColumn_TenDoiTac
            // 
            this.gridColumn_TenDoiTac.Caption = "Họ tên";
            this.gridColumn_TenDoiTac.FieldName = "TenDoiTac";
            this.gridColumn_TenDoiTac.Name = "gridColumn_TenDoiTac";
            this.gridColumn_TenDoiTac.Visible = true;
            this.gridColumn_TenDoiTac.VisibleIndex = 0;
            this.gridColumn_TenDoiTac.Width = 242;
            // 
            // gridColumn_Lop
            // 
            this.gridColumn_Lop.Caption = "Lớp";
            this.gridColumn_Lop.FieldName = "MaLop";
            this.gridColumn_Lop.Name = "gridColumn_Lop";
            this.gridColumn_Lop.Visible = true;
            this.gridColumn_Lop.VisibleIndex = 1;
            this.gridColumn_Lop.Width = 894;
            // 
            // txtMaNienHoc
            // 
            this.txtMaNienHoc.Location = new System.Drawing.Point(153, 128);
            this.txtMaNienHoc.MaxLength = 50;
            this.txtMaNienHoc.Name = "txtMaNienHoc";
            this.txtMaNienHoc.Size = new System.Drawing.Size(122, 23);
            this.txtMaNienHoc.TabIndex = 2;
            this.txtMaNienHoc.TextChanged += new System.EventHandler(this.txtMaNienHoc_TextChanged);
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(24, 131);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(57, 16);
            this.label7.TabIndex = 1;
            this.label7.Text = "Niên học";
            this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label12
            // 
            this.label12.AutoSize = true;
            this.label12.Location = new System.Drawing.Point(466, 131);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(28, 16);
            this.label12.TabIndex = 5;
            this.label12.Text = "Lớp";
            this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // cboLop
            // 
            this.cboLop.FormattingEnabled = true;
            this.cboLop.Location = new System.Drawing.Point(568, 127);
            this.cboLop.Name = "cboLop";
            this.cboLop.Size = new System.Drawing.Size(176, 24);
            this.cboLop.TabIndex = 6;
            this.cboLop.SelectedIndexChanged += new System.EventHandler(this.cboLop_SelectedIndexChanged);
            // 
            // pictureBox2
            // 
            this.pictureBox2.Dock = System.Windows.Forms.DockStyle.Top;
            //this.pictureBox2.Image = global::CNCSoft.ErpApps.TMS.Properties.Resources.frmKT_TienMat_PhieuThu_HP;
            this.pictureBox2.Location = new System.Drawing.Point(0, 0);
            this.pictureBox2.Name = "pictureBox2";
            this.pictureBox2.Size = new System.Drawing.Size(825, 45);
            this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.pictureBox2.TabIndex = 333;
            this.pictureBox2.TabStop = false;
            // 
            // panel1
            // 
            this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.panel1.Controls.Add(this.txtSoChungTu);
            this.panel1.Controls.Add(this.label8);
            this.panel1.Controls.Add(this.label9);
            this.panel1.Controls.Add(this.txtNgayChungTu);
            this.panel1.Location = new System.Drawing.Point(0, 47);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(816, 66);
            this.panel1.TabIndex = 39;
            // 
            // dgridChiTietPT
            // 
            this.dgridChiTietPT.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.dgridChiTietPT.Location = new System.Drawing.Point(153, 431);
            this.dgridChiTietPT.MainView = this.gridView2;
            this.dgridChiTietPT.Name = "dgridChiTietPT";
            this.dgridChiTietPT.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
            this.repositoryItemCalcEdit_SoLuong,
            this.repositoryItemTextEdit_So,
            this.repositoryItemLookUpEdit_TaiKhoan,
            this.repositoryItemTextEdit_NhapSoLuong});
            this.dgridChiTietPT.Size = new System.Drawing.Size(592, 0);
            this.dgridChiTietPT.TabIndex = 38;
            this.dgridChiTietPT.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
            this.gridView2});
            this.dgridChiTietPT.Visible = false;
            // 
            // gridView2
            // 
            this.gridView2.Appearance.ColumnFilterButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.ColumnFilterButton.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.ColumnFilterButton.ForeColor = System.Drawing.Color.White;
            this.gridView2.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView2.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView2.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView2.Appearance.ColumnFilterButtonActive.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(216)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.ColumnFilterButtonActive.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(216)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.ColumnFilterButtonActive.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView2.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView2.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView2.Appearance.Empty.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.Empty.BackColor2 = System.Drawing.Color.White;
            this.gridView2.Appearance.Empty.Options.UseBackColor = true;
            this.gridView2.Appearance.EvenRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(251)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.EvenRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(251)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.EvenRow.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView2.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView2.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView2.Appearance.FilterCloseButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.FilterCloseButton.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.FilterCloseButton.ForeColor = System.Drawing.Color.White;
            this.gridView2.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView2.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView2.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView2.Appearance.FilterPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.FilterPanel.BackColor2 = System.Drawing.Color.White;
            this.gridView2.Appearance.FilterPanel.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView2.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView2.Appearance.FixedLine.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(133)))), ((int)(((byte)(195)))));
            this.gridView2.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView2.Appearance.FocusedCell.BackColor = System.Drawing.Color.White;
            this.gridView2.Appearance.FocusedCell.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView2.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView2.Appearance.FocusedRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(38)))), ((int)(((byte)(109)))), ((int)(((byte)(189)))));
            this.gridView2.Appearance.FocusedRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(139)))), ((int)(((byte)(206)))));
            this.gridView2.Appearance.FocusedRow.ForeColor = System.Drawing.Color.White;
            this.gridView2.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView2.Appearance.FocusedRow.Options.UseBorderColor = true;
            this.gridView2.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView2.Appearance.FooterPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.FooterPanel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.FooterPanel.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView2.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView2.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView2.Appearance.GroupButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.GroupButton.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView2.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView2.Appearance.GroupFooter.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(216)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.GroupFooter.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(216)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.GroupFooter.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView2.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView2.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView2.Appearance.GroupPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.GroupPanel.BackColor2 = System.Drawing.Color.White;
            this.gridView2.Appearance.GroupPanel.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView2.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView2.Appearance.GroupRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(216)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.GroupRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(216)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.GroupRow.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView2.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView2.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView2.Appearance.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(139)))), ((int)(((byte)(201)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.HeaderPanel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(139)))), ((int)(((byte)(201)))), ((int)(((byte)(254)))));
            this.gridView2.Appearance.HeaderPanel.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView2.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView2.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView2.Appearance.HideSelectionRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(105)))), ((int)(((byte)(170)))), ((int)(((byte)(225)))));
            this.gridView2.Appearance.HideSelectionRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(83)))), ((int)(((byte)(155)))), ((int)(((byte)(215)))));
            this.gridView2.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView2.Appearance.HideSelectionRow.Options.UseBorderColor = true;
            this.gridView2.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView2.Appearance.HorzLine.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView2.Appearance.OddRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.OddRow.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.OddRow.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView2.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView2.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView2.Appearance.Preview.Font = new System.Drawing.Font("Verdana", 7.5F);
            this.gridView2.Appearance.Preview.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(83)))), ((int)(((byte)(155)))), ((int)(((byte)(215)))));
            this.gridView2.Appearance.Preview.Options.UseFont = true;
            this.gridView2.Appearance.Preview.Options.UseForeColor = true;
            this.gridView2.Appearance.Row.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(251)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.Row.ForeColor = System.Drawing.Color.Black;
            this.gridView2.Appearance.Row.Options.UseBackColor = true;
            this.gridView2.Appearance.Row.Options.UseForeColor = true;
            this.gridView2.Appearance.RowSeparator.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(246)))), ((int)(((byte)(255)))));
            this.gridView2.Appearance.RowSeparator.BackColor2 = System.Drawing.Color.White;
            this.gridView2.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView2.Appearance.SelectedRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(83)))), ((int)(((byte)(155)))), ((int)(((byte)(215)))));
            this.gridView2.Appearance.SelectedRow.ForeColor = System.Drawing.Color.White;
            this.gridView2.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView2.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView2.Appearance.TopNewRow.BackColor = System.Drawing.Color.White;
            this.gridView2.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView2.Appearance.VertLine.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(104)))), ((int)(((byte)(184)))), ((int)(((byte)(251)))));
            this.gridView2.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView2.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
            this.gridColumn_TaiKhoanCo,
            this.gridColumn_TieuKhoanCo,
            this.gridColumn_DienGiai,
            this.gridColumn_SoLuong,
            this.gridColumn_DonGia,
            this.gridColumn_ThanhTien,
            this.gridColumn_SoTienMienGiam,
            this.gridColumn_TaiKhoanNo,
            this.gridColumn_TieuKhoanNo});
            this.gridView2.GridControl = this.dgridChiTietPT;
            this.gridView2.Name = "gridView2";
            this.gridView2.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.True;
            this.gridView2.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView2.OptionsView.EnableAppearanceOddRow = true;
            this.gridView2.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            this.gridView2.OptionsView.ShowFooter = true;
            this.gridView2.OptionsView.ShowGroupPanel = false;
            this.gridView2.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.gridView2_CellValueChanged);
            this.gridView2.ValidateRow += new DevExpress.XtraGrid.Views.Base.ValidateRowEventHandler(this.gridView2_ValidateRow);
            // 
            // gridColumn_TaiKhoanCo
            // 
            this.gridColumn_TaiKhoanCo.Caption = "TK CO";
            this.gridColumn_TaiKhoanCo.ColumnEdit = this.repositoryItemLookUpEdit_TaiKhoan;
            this.gridColumn_TaiKhoanCo.FieldName = "TaiKhoanCo";
            this.gridColumn_TaiKhoanCo.Name = "gridColumn_TaiKhoanCo";
            this.gridColumn_TaiKhoanCo.Visible = true;
            this.gridColumn_TaiKhoanCo.VisibleIndex = 0;
            // 
            // repositoryItemLookUpEdit_TaiKhoan
            // 
            this.repositoryItemLookUpEdit_TaiKhoan.AutoHeight = false;
            this.repositoryItemLookUpEdit_TaiKhoan.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.repositoryItemLookUpEdit_TaiKhoan.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
            new DevExpress.XtraEditors.Controls.LookUpColumnInfo("MaTaiKhoan", "MaTK"),
            new DevExpress.XtraEditors.Controls.LookUpColumnInfo("TenTaiKhoanVN", "Tên")});
            this.repositoryItemLookUpEdit_TaiKhoan.DisplayMember = "MaTaiKhoan";
            this.repositoryItemLookUpEdit_TaiKhoan.Name = "repositoryItemLookUpEdit_TaiKhoan";
            this.repositoryItemLookUpEdit_TaiKhoan.NullText = "";
            this.repositoryItemLookUpEdit_TaiKhoan.ShowDropDown = DevExpress.XtraEditors.Controls.ShowDropDown.DoubleClick;
            this.repositoryItemLookUpEdit_TaiKhoan.ValueMember = "MaTaiKhoan";
            // 
            // gridColumn_TieuKhoanCo
            // 
            this.gridColumn_TieuKhoanCo.Caption = "Tiểu khoản có";
            this.gridColumn_TieuKhoanCo.FieldName = "MaTieuKhoanCo1";
            this.gridColumn_TieuKhoanCo.Name = "gridColumn_TieuKhoanCo";
            this.gridColumn_TieuKhoanCo.Visible = true;
            this.gridColumn_TieuKhoanCo.VisibleIndex = 1;
            // 
            // gridColumn_DienGiai
            // 
            this.gridColumn_DienGiai.Caption = "Diễn giải";
            this.gridColumn_DienGiai.FieldName = "DienGiaiChiTiet";
            this.gridColumn_DienGiai.Name = "gridColumn_DienGiai";
            this.gridColumn_DienGiai.Visible = true;
            this.gridColumn_DienGiai.VisibleIndex = 2;
            // 
            // gridColumn_SoLuong
            // 
            this.gridColumn_SoLuong.Caption = "Số lượng";
            this.gridColumn_SoLuong.ColumnEdit = this.repositoryItemTextEdit_NhapSoLuong;
            this.gridColumn_SoLuong.FieldName = "SoLuong";
            this.gridColumn_SoLuong.Name = "gridColumn_SoLuong";
            this.gridColumn_SoLuong.Visible = true;
            this.gridColumn_SoLuong.VisibleIndex = 3;
            // 
            // repositoryItemTextEdit_NhapSoLuong
            // 
            this.repositoryItemTextEdit_NhapSoLuong.AutoHeight = false;
            this.repositoryItemTextEdit_NhapSoLuong.DisplayFormat.FormatString = "N2";
            this.repositoryItemTextEdit_NhapSoLuong.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemTextEdit_NhapSoLuong.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemTextEdit_NhapSoLuong.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            this.repositoryItemTextEdit_NhapSoLuong.Name = "repositoryItemTextEdit_NhapSoLuong";
            // 
            // gridColumn_DonGia
            // 
            this.gridColumn_DonGia.Caption = "Đơn giá";
            this.gridColumn_DonGia.ColumnEdit = this.repositoryItemTextEdit_So;
            this.gridColumn_DonGia.FieldName = "DonGia";
            this.gridColumn_DonGia.Name = "gridColumn_DonGia";
            this.gridColumn_DonGia.Visible = true;
            this.gridColumn_DonGia.VisibleIndex = 4;
            // 
            // repositoryItemTextEdit_So
            // 
            this.repositoryItemTextEdit_So.AutoHeight = false;
            this.repositoryItemTextEdit_So.DisplayFormat.FormatString = "N0";
            this.repositoryItemTextEdit_So.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemTextEdit_So.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemTextEdit_So.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            this.repositoryItemTextEdit_So.Name = "repositoryItemTextEdit_So";
            // 
            // gridColumn_ThanhTien
            // 
            this.gridColumn_ThanhTien.Caption = "Số tiền";
            this.gridColumn_ThanhTien.ColumnEdit = this.repositoryItemTextEdit_So;
            this.gridColumn_ThanhTien.FieldName = "SoTien";
            this.gridColumn_ThanhTien.Name = "gridColumn_ThanhTien";
            this.gridColumn_ThanhTien.OptionsColumn.ReadOnly = true;
            this.gridColumn_ThanhTien.SummaryItem.DisplayFormat = "{0:0}";
            this.gridColumn_ThanhTien.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            this.gridColumn_ThanhTien.Visible = true;
            this.gridColumn_ThanhTien.VisibleIndex = 5;
            // 
            // gridColumn_SoTienMienGiam
            // 
            this.gridColumn_SoTienMienGiam.Caption = "Miễn giảm";
            this.gridColumn_SoTienMienGiam.ColumnEdit = this.repositoryItemTextEdit_So;
            this.gridColumn_SoTienMienGiam.FieldName = "SoTienMienGiam";
            this.gridColumn_SoTienMienGiam.Name = "gridColumn_SoTienMienGiam";
            this.gridColumn_SoTienMienGiam.Visible = true;
            this.gridColumn_SoTienMienGiam.VisibleIndex = 6;
            // 
            // gridColumn_TaiKhoanNo
            // 
            this.gridColumn_TaiKhoanNo.Caption = "TK NO";
            this.gridColumn_TaiKhoanNo.ColumnEdit = this.repositoryItemLookUpEdit_TaiKhoan;
            this.gridColumn_TaiKhoanNo.FieldName = "TaiKhoanNo";
            this.gridColumn_TaiKhoanNo.Name = "gridColumn_TaiKhoanNo";
            this.gridColumn_TaiKhoanNo.Visible = true;
            this.gridColumn_TaiKhoanNo.VisibleIndex = 7;
            // 
            // gridColumn_TieuKhoanNo
            // 
            this.gridColumn_TieuKhoanNo.Caption = "Tiểu khoản nợ";
            this.gridColumn_TieuKhoanNo.FieldName = "MaTieuKhoanNo1";
            this.gridColumn_TieuKhoanNo.Name = "gridColumn_TieuKhoanNo";
            this.gridColumn_TieuKhoanNo.Visible = true;
            this.gridColumn_TieuKhoanNo.VisibleIndex = 8;
            // 
            // repositoryItemCalcEdit_SoLuong
            // 
            this.repositoryItemCalcEdit_SoLuong.AutoHeight = false;
            this.repositoryItemCalcEdit_SoLuong.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.repositoryItemCalcEdit_SoLuong.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemCalcEdit_SoLuong.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.repositoryItemCalcEdit_SoLuong.Name = "repositoryItemCalcEdit_SoLuong";
            // 
            // txtMaCheDo
            // 
            this.txtMaCheDo.Location = new System.Drawing.Point(712, 160);
            this.txtMaCheDo.MaxLength = 50;
            this.txtMaCheDo.Name = "txtMaCheDo";
            this.txtMaCheDo.ReadOnly = true;
            this.txtMaCheDo.Size = new System.Drawing.Size(34, 23);
            this.txtMaCheDo.TabIndex = 11;
            this.txtMaCheDo.TabStop = false;
            // 
            // txtMaCoSo
            // 
            this.txtMaCoSo.Location = new System.Drawing.Point(334, 128);
            this.txtMaCoSo.Name = "txtMaCoSo";
            this.txtMaCoSo.RefField = null;
            this.txtMaCoSo.RefTable = null;
            this.txtMaCoSo.Size = new System.Drawing.Size(33, 23);
            this.txtMaCoSo.TabIndex = 4;
            this.txtMaCoSo.TabStop = false;
            this.txtMaCoSo.TextChanged += new System.EventHandler(this.txtMaCoSo_TextChanged);
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(291, 131);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(40, 16);
            this.label5.TabIndex = 3;
            this.label5.Text = "Cơ sở";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // lblThucThu
            // 
            this.lblThucThu.AutoSize = true;
            this.lblThucThu.Location = new System.Drawing.Point(24, 290);
            this.lblThucThu.Name = "lblThucThu";
            this.lblThucThu.Size = new System.Drawing.Size(99, 16);
            this.lblThucThu.TabIndex = 20;
            this.lblThucThu.Text = "Số tiền thực thu";
            this.lblThucThu.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label13
            // 
            this.label13.AutoSize = true;
            this.label13.Location = new System.Drawing.Point(419, 385);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(44, 16);
            this.label13.TabIndex = 35;
            this.label13.Text = "Mã HP";
            this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label15
            // 
            this.label15.AutoSize = true;
            this.label15.Location = new System.Drawing.Point(464, 293);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(49, 16);
            this.label15.TabIndex = 22;
            this.label15.Text = "Còn dư";
            this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label14
            // 
            this.label14.AutoSize = true;
            this.label14.Location = new System.Drawing.Point(464, 262);
            this.label14.Name = "label14";
            this.label14.Size = new System.Drawing.Size(76, 16);
            this.label14.TabIndex = 18;
            this.label14.Text = "Số dư trước";
            this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label11
            // 
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(22, 261);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(98, 16);
            this.label11.TabIndex = 16;
            this.label11.Text = "Số tiền phải thu";
            this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // TienMatPhieuThuLe
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 16);
            this.BackColor = System.Drawing.Color.WhiteSmoke;
            this.ClientSize = new System.Drawing.Size(825, 528);
            this.Controls.Add(this.txtSoDuThangNay);
            this.Controls.Add(this.label15);
            this.Controls.Add(this.txtSoDuThangTruoc);
            this.Controls.Add(this.label14);
            this.Controls.Add(this.txtSoTien);
            this.Controls.Add(this.label11);
            this.Controls.Add(this.label13);
            this.Controls.Add(this.txtMaHocPhi);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.txtMaCoSo);
            this.Controls.Add(this.txtMaCheDo);
            this.Controls.Add(this.lstAddnew);
            this.Controls.Add(this.dgridChiTietPT);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.txtSoTienThucThu);
            this.Controls.Add(this.lblThucThu);
            this.Controls.Add(this.cboLop);
            this.Controls.Add(this.label12);
            this.Controls.Add(this.txtMaNienHoc);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.gridLookUpEdit_txtMaHocSinh);
            this.Controls.Add(this.cboNganHang);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.txtNgayHoaDon);
            this.Controls.Add(this.label18);
            this.Controls.Add(this.txtSerialHoaDon);
            this.Controls.Add(this.label17);
            this.Controls.Add(this.txtSoHoaDon);
            this.Controls.Add(this.label16);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.txtDiaChi);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.txtDienGiai);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.txtHoTenNguoiNopTien);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.cmdXemTK);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.pictureBox2);
            this.Controls.Add(this.pnlButtons);
            this.Controls.Add(this.cboLyDoThu);
            this.Controls.Add(this.pnlBottom);
            this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.KeyPreview = true;
            this.MinimumSize = new System.Drawing.Size(841, 566);
            this.Name = "TienMatPhieuThuLe";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Tag = "";
            this.Text = "Phiếu thu học phí";
            this.Load += new System.EventHandler(this.TienMatPhieuThuLe_Load);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TienMatPhieuThuHocphi_KeyDown);
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit1)).EndInit();
            this.pnlButtons.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.picboxNote)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.picboxHelp)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.ep)).EndInit();
            this.pnlBottom.ResumeLayout(false);
            this.pnlNevigator.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.gridLookUpEdit_txtMaHocSinh.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridLookUpEdit_txtMaHocSinhView)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dgridChiTietPT)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridView2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemLookUpEdit_TaiKhoan)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit_NhapSoLuong)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemTextEdit_So)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCalcEdit_SoLuong)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		#region [ Command Events ]
		    bool cancelHandlers;
		    TienMatPhieuThuLeData ptData;
		    BindingManagerBase bmb;
        
            //Cac bien phan quyen tren form
            bool DuocQuyenThem = true;
            bool DuocQuyenSua = true;
            bool DuocQuyenXoa = true;

		#endregion

		private void TienMatPhieuThuLe_Load(object sender, System.EventArgs e) {
			cancelHandlers = true;
			try {
				ptData = new TienMatPhieuThuLeData();

				intiDatabinding();

				//ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).ColumnChanged +=new DataColumnChangeEventHandler(TienMatPhieuThuHocphi_ColumnChanged);
                //ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).RowDeleted += new DataRowChangeEventHandler(TienMatPhieuThuHocphi_RowDeleted);
				
				bmb = this.BindingContext[ptData.getDataSet(), "TienMatPT"];

				bmb.PositionChanged +=new EventHandler(bmb_PositionChanged);

			} catch {
				MessageBox.Show(this, RS.ERROR_LOAD_FORM, RS.ERROR_LOAD_FORM_CAPTION, 
					MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			} finally {
				cancelHandlers = false;
			}

            PublicFunction.PhanQuyenForm(this.Name, GlobalVariable.WSInfo.UserID, out DuocQuyenThem, out DuocQuyenSua, out DuocQuyenXoa);

            if (DuocQuyenThem)
            {
                //cmdAddNew_Click(cmdAddNew, e);
                setEditMode(false);
                sendStatus("Chọn <Thêm> và loại chứng từ cần thêm mới", false);
            }
            else
            {
                setEditMode(false);
                sendStatus("Bạn không có quyền thêm mới", false);
            }

            DataTable dtTK = new DataTable();
            SQLHelper.Fill(dtTK, GlobalVariable.WSInfo.ConnectionString, "SELECT * FROM DM_TAIKHOAN");
            repositoryItemLookUpEdit_TaiKhoan.DataSource = dtTK;

            
		}

		private void bmb_PositionChanged(object sender, System.EventArgs e) {
			if (cancelHandlers) return;

			cancelHandlers = true;
			if (bmb.Count == 0) {
				this.lblRecordInfo.Text = "0/0";
			} else {
				this.lblRecordInfo.Text = (bmb.Position +1) +"/" +bmb.Count;
			}

			cancelHandlers = false;
		}

		private void TienMatPhieuThuHocphi_RowDeleted(object sender, DataRowChangeEventArgs e) {
            if (ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length > 0)
            {
                this["ThucThu"] = ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Compute("Sum(SoTien)", "SoChungTu='" + this["SoChungTu"] + "'");
			} 
            else {
			   this["ThucThu"] = 0;
			}
			bmb.EndCurrentEdit();
            bmb_PositionChanged(bmb, e);
		}

		private void TienMatPhieuThuHocphi_ColumnChanged(object sender, DataColumnChangeEventArgs e) {
            /*
            if (cancelHandlers) return;
			cancelHandlers = true;
            //MessageBox.Show(e.Column.ColumnName);  

            try
            {
                if (e.Column.ColumnName.ToUpper() == "SOTIEN" || e.Column.ColumnName.ToUpper() == "SOTIENMIENGIAM" || e.Column.ColumnName.ToUpper() == "SOLUONG" || e.Column.ColumnName.ToUpper() == "DONGIA" || e.Column.ColumnName.ToUpper() == "THUESUAT" || e.Column.ColumnName.ToUpper() == "TIGIA")
                {

                    double sumSoTien = 0;
                    double sumSoTienMienGiam = 0;

                    if (!(e.Row["SoLuong"] is DBNull) && !(e.Row["DonGia"] is DBNull))
                        e.Row["SoTien"] = Convert.ToDouble(e.Row["SoLuong"]) * Convert.ToDouble(e.Row["DonGia"]);


                    if (e.Row["SoTien"] is DBNull) e.Row["SoTien"] = 0;
                    if (e.Row["SoTienMienGiam"] is DBNull) e.Row["SoTienMienGiam"] = 0;

                    double soTien = (double)(decimal)e.Row["SoTien"];
                    double soTienMienGiam = (double)(decimal)e.Row["SoTienMienGiam"];

                    sumSoTien = soTien - soTienMienGiam;

                    int numOfRow = ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length;

                    if (numOfRow > 0)
                    {
                        sumSoTien = (double)(decimal)ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Compute("Sum(SoTien)", "SoChungTu='" + this["SoChungTu"] + "'");
                        sumSoTienMienGiam = (double)(decimal)ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Compute("Sum(SoTienMienGiam)", "SoChungTu='" + this["SoChungTu"] + "'");
                        //if (numOfRow == dgridChiTietPT  )
                        //{ // dgridChiTietPT.CurrentCell.RowNumber
                        //	sumSoTien += soTien;
                        //}
                    }
                    this["ThucThu"] = sumSoTien - sumSoTienMienGiam; //Chi thay doi so thuc thu, con so tong tien la so phai thu (ko thay doi gi, chi lay ra tu KH)
                    
                    bmb.EndCurrentEdit();
                    bmb_PositionChanged(bmb, e);

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally {
				cancelHandlers = false;
			}
            */
             
		}

        
		#region [ Commond Methods ]

		private void intiDatabinding() {
			this.txtSoChungTu.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SoChungTu");
			this.txtNgayChungTu.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.NgayChungTu");
			this.txtNgayChungTu.ActiveDisplayFormat();
            
            this.gridLookUpEdit_txtMaHocSinh.DataBindings.Add("EditValue", ptData.getDataSet(), "TienMatPT.MaDoiTac");
            gridLookUpEdit_txtMaHocSinh.Properties.DataSource = ptData.getTable(TienMatPhieuThuLeData.TL.DoiTac);
            this.gridLookUpEdit_txtMaHocSinh.Properties.DisplayMember = "TenDoiTac";
            this.gridLookUpEdit_txtMaHocSinh.Properties.ValueMember = "MaDoiTac";


            this.txtMaNienHoc.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.MaNienHoc");
            this.cboLop.DataBindings.Add("SelectedValue", ptData.getDataSet(), "TienMatPT.MaLop");
            this.txtMaCoSo.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.MaCoSo");

            this.txtDiaChi.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.DiaChi");
			this.txtDienGiai.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.DienGiai");
			this.txtHoTenNguoiNopTien.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.Hoten");
            this.txtMaCheDo.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.MaCheDo");


            //So tien phai thu (luu vao TONGTIEN)
            this.txtSoTien.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.TongTien");
            this.txtSoTien.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThuHocphi_Parse);
            this.txtSoTien.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThuHocphi_Format);

            //So tien thuc thu (luu vao THUCTHU)
            this.txtSoTienThucThu.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.ThucThu");
            this.txtSoTienThucThu.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThuHocphi_Parse);
            this.txtSoTienThucThu.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThuHocphi_Format);

            //So du thang truoc
            this.txtSoDuThangTruoc.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SoDuThangTruoc");
            this.txtSoDuThangTruoc.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThuHocphi_Parse);
            this.txtSoDuThangTruoc.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThuHocphi_Format);

            //So du thang nay
            this.txtSoDuThangNay.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SoDuThangNay");
            this.txtSoDuThangNay.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThuHocphi_Parse);
            this.txtSoDuThangNay.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThuHocphi_Format);


            //Ly do thu (dung de dinh khoan)
            this.cboLyDoThu.DataBindings.Add("SelectedValue", ptData.getDataSet(), "TienMatPT.LyDoThuChi");
            this.cboLyDoThu.DataSource = ptData.getTable(TienMatPhieuThuLeData.TL.LyDoThuHP);
            this.cboLyDoThu.DisplayMember = "TenHocPhi";
            this.cboLyDoThu.ValueMember = "MaHocPhi";

            //Ma loai chung tu (dung de chon khi addnew, ko binding
            this.lstAddnew.DataSource = ptData.getTable(TienMatPhieuThuLeData.TL.ListAddNew);
            this.lstAddnew.DisplayMember= "TenLoaiChungTu";
            this.lstAddnew.ValueMember = "MaLoaiChungTu";

            //Ngan hang
            this.cboNganHang.DataBindings.Add("SelectedValue", ptData.getDataSet(), "TienMatPT.MaNganHang");
            this.cboNganHang.DataSource = ptData.getTable(TienMatPhieuThuLeData.TL.NganHang);
            this.cboNganHang.DisplayMember = "TenNganHang";
            this.cboNganHang.ValueMember = "MaNganHang";

            this.txtSoHoaDon.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SoHoaDon");
            this.txtSerialHoaDon.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SerialHoaDon");
            this.txtNgayHoaDon.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.NgayHoaDon");
            this.txtNgayHoaDon.ActiveDisplayFormat();

            this.txtMaHocPhi.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.MaHocPhi");

            dgridChiTietPT.DataSource = ptData.getDataSet();
            dgridChiTietPT.DataMember =  "TienMatPT.M_D";
		}

		private void TienMatPhieuThuHocphi_Parse(object sender, ConvertEventArgs e) {
			try {
				if (e.Value == null || (string)e.Value == string.Empty) {
					e.Value = DBNull.Value;
				} else {
					e.Value = double.Parse((string)e.Value);
				}
			} catch {
				sendStatus("Bạn vui lòng nhập đúng định dạng số.", true);
			}
		}

        private void TienMatPhieuThuHocphi_Format(object sender, ConvertEventArgs e)
        {
			try {
				if (Convert.IsDBNull(e.Value)) {
					e.Value = "";
				} else {
					e.Value = ((decimal)e.Value).ToString("N0");
				}
			} catch (Exception ex) {
				//sendStatus("Unexpected Error: " +ex.Message, true); //Ko can thiet, gay roi
			}
		}

		DataGridAutoResizeSupporter dgridARS = new DataGridAutoResizeSupporter();
		DataGridStyleFactory dgridSF = new DataGridStyleFactory();


		private void setEditMode(bool edit) {

			cmdAddNew.Enabled = !edit  && DuocQuyenThem ;
			cmdDelete.Enabled = !edit && bmb.Position >= 0 && DuocQuyenXoa ;
			cmdModify.Enabled = !edit && bmb.Position >= 0  && DuocQuyenSua ;
			cmdPrint.Enabled = !edit && bmb.Position >= 0;
			cmdView.Enabled = !edit;
			cmdUpdate.Enabled = edit;
			cmdCancel.Enabled = edit;

			cmdMoveFirst.Enabled = !edit;
			cmdMovePrevious.Enabled = !edit;
			cmdMoveNext.Enabled = !edit;
			cmdMoveLast.Enabled = !edit;

            txtSoChungTu.ReadOnly = true;
			txtNgayChungTu.ReadOnly = !edit;
            txtMaNienHoc.ReadOnly = !edit;
            cboLop.Enabled = edit;
            gridLookUpEdit_txtMaHocSinh.Properties.ReadOnly = !edit;
            txtDiaChi.ReadOnly = !edit;
            txtHoTenNguoiNopTien.ReadOnly = !edit;
            cboLyDoThu.Enabled = edit;

            txtSoTienThucThu.ReadOnly = !edit;
            txtDienGiai.ReadOnly = !edit;
			
            txtSoHoaDon.ReadOnly = !edit;
            txtNgayHoaDon.ReadOnly= !edit;
            txtSerialHoaDon.ReadOnly = !edit;
  
			gridView2.OptionsBehavior.ReadOnly = !edit;
			cmdXemTK.Enabled = bmb.Position >= 0;

            try
            {
                cboNganHang.Enabled = ptData.TaiKhoanMacDinh == "1121";
                txtSoHoaDon.Enabled = ptData.TaiKhoanMacDinh != "1311";
                txtSerialHoaDon.Enabled = ptData.TaiKhoanMacDinh != "1311";
                txtNgayHoaDon.Enabled = ptData.TaiKhoanMacDinh != "1311";
            }
            catch { }
		}

		#endregion

		#region [ Command Events ]

		private void cmdAddNew_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;

            if (ptData.createNewRow(GlobalVariable.WSInfo["TienMat.PhieuThuHP.MaLoaiCT", "HP"]))
            {
				bmb.Position = bmb.Count -1;
				setEditMode(true);
                gridLookUpEdit_txtMaHocSinh.Focus();
			}
			cancelHandlers= false;
			bmb_PositionChanged(bmb, e);
			sendStatus("Đang trong trạng thái thêm mới...", false);


            cboLyDoThu.SelectedIndex = -1; 
		}

		private void cmdSave_Click(object sender, System.EventArgs e) {
            
            ep.Clear();

            if (txtSoChungTu.Text == "") return;

            //Kiem tra su giong nhau giua sochungtu va ngaychungtu
            if (txtNgayChungTu.getDateValue(true).Year.ToString().Substring(2, 2) != txtSoChungTu.Text.Substring(2, 2) || txtNgayChungTu.getDateValue(true).Month.ToString("00") != txtSoChungTu.Text.Substring(4, 2))
            {
                MessageBox.Show("Thời gian làm việc không đúng với ngày chứng từ \nBạn phải login vào chương trình với ngày làm việc thuộc tháng " +
                                              txtNgayChungTu.getDateValue(true).Month.ToString() + " năm " + txtNgayChungTu.getDateValue(true).Year.ToString(),
                                              "Chon sai ngay lam viec", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ep.SetError(txtSoChungTu, "Chọn lại ngày làm việc ngay ở màn hình đăng nhập ban đầu để đánh số chứng từ cho đúng");
                return;
            }

            //Kiem tra so lieu truoc khi luu
            if (gridLookUpEdit_txtMaHocSinh.EditValue.ToString() == "")
            {
                ep.SetError(gridLookUpEdit_txtMaHocSinh, "Bạn vui lòng chọn Học sinh");
                gridLookUpEdit_txtMaHocSinh.Focus();
				showEP = true;
				return;
			}
            if (cboLyDoThu.SelectedIndex == -1)
            {
                ep.SetError(cboLyDoThu, "Vui lòng chọn lý do thu tiền để chúng tôi hạch toán chứng từ");
                cboLyDoThu.Focus();
                showEP = true;
                return;
            }


            //Nếu chứng từ là HP thì phải có thông tin hóa đơn
            /*
            if (txtSoChungTu.Text.Substring(0,2) == "HP")
            {
                if (txtSoHoaDon.Text.Trim() == "")
                {
                    ep.SetError(txtSoHoaDon, "Chưa có số hóa đơn thu học phí");
                    txtSoHoaDon.Focus();
                    return;
                }
                if (txtSerialHoaDon.Text.Trim() == "")
                {
                    ep.SetError(txtSerialHoaDon, "Chưa có số serial hóa đơn thu học phí");
                    txtSerialHoaDon.Focus();
                    return;
                }
            }
            */

            //Nếu chứng từ là NH thì phải có MaNganHang
            if (txtSoChungTu.Text.Substring(0,2) == "NH")
            {
                if (cboNganHang.SelectedIndex == -1)
                {
                    ep.SetError(cboNganHang, "Chưa chọn Ngân hàng nhận học phí");
                    cboNganHang.Focus();
                    return;
                }
            }

            //Tinh toan lai các kiểu tiền cho đúng trước khi lưu
            TinhToanTien();

            //Bat dau LU
			// dont regard to this code
			//try {
			//	dgridChiTietPT.CurrentCell = 
			//		new DataGridCell(dgridChiTietPT.CurrentCell.RowNumber +1, 
			//		dgridChiTietPT.CurrentCell.ColumnNumber);
			//} catch {}

			cancelHandlers = true;
			bmb.EndCurrentEdit();
			if (ptData.update()) {
				setEditMode(false);
                sendStatus("Đã lưu phiếu thu " + txtSoChungTu.Text  , false);
                ptData.initData("('" + txtSoChungTu.Text + "')", false);
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdCancel_Click(object sender, System.EventArgs e) {
            cancelHandlers = true;
            try
            {
                bmb.EndCurrentEdit();
                sendStatus("Bỏ qua, không cập nhật", false);
                DialogResult dr = DialogResult.Yes;
                if (ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).GetChanges() != null &&
                    ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).GetChanges() != null)
                {
                    dr = MessageBox.Show(this, RS.CANCEL_UPDATE, RS.CANCEL_UPDATE_CAPTION,
                        MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                }

                if (dr == DialogResult.Yes)
                {
                    cancelHandlers = true;
                    ptData.getDataSet().RejectChanges();
                    cancelHandlers = false;
                    setEditMode(false);
                    bmb_PositionChanged(bmb, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cancelHandlers = false;
		}

		FormView fv = null;
		private void cmdView_Click(object sender, System.EventArgs e) {
            gridLookUpEdit_txtMaHocSinhView.ClearColumnsFilter();
			if (fv == null) {
                fv = new FormView("Select SoChungtu, convert(varchar, NgayChungtu, 103) as NgayChungTu, HoTen, DienGiai, TongtienUSD, Tigia, TongTien, PhanTramDiscount, TongTienDiscount, ThucThu, isnull(SoChungTuCu, '') as SoChungTuCu, " +
                    "SoHoadon, SerialHoadon, NgayHoadon, UpdateUserID " +
                    "from TienMat WHERE MaLoaiChungTu in (SELECT maloaichungtu FROM dm_maloaichungtu WHERE form = 'HP') and MaHocPhi = 'B01' " +
                    "and SoInvoice is null " +
                    "order by NgayChungTu, SoChungTu ", 
                    GlobalVariable.WSInfo.ConnectionString,
                    GlobalVariable.WSInfo.WorkingDate );
				fv.DateFilterColumns = new string[,] {{"NgayChungTu", "Ngày chứng từ"}, {"UpdateDate", "Ngày cập nhật"}};
                //fv.CollumnFocusInFilterGrid = 2;
			}
			fv.ShowDialog(this);
			if (fv.DialogResult == DialogResult.OK) {
				cancelHandlers = true;
                
                //Truong hop lay phieu cu thi fill ton bo ly do thu (khong loc theo loai chung tu khi chon nhap moi)
                //this.cboLyDoThu.DataSource = ptData.getTable(TienMatPhieuThuHocphiData.TL.LyDoThuHP);

				ptData.initData(fv.SelectedIDs, false);
				setEditMode(false);
                cancelHandlers = false;

				bmb_PositionChanged(bmb, e);
			}			
		}

		private void cmdModify_Click(object sender, System.EventArgs e) {
			if (bmb.Position >= 0) {
				bmb.EndCurrentEdit();
				setEditMode(true);
                sendStatus("Đang trong trạng sửa phiếu thu " + txtSoChungTu.Text  , false);
                //if (ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length > 1)
                //{
					//
                    //dgridChiTietPT.Visible = false ;
                    //this.Size = this.MinimumSize;
                    //cmdXemTK_Click(cmdXemTK, e);
                    //Disable nhung textbox ko the sua neu co nhieu dong o chi tiet
                    //txtSoTien.Enabled = false;
                    //cboLyDoThu.Enabled = false; 
				//}
			}
		}

		private void cmdDelete_Click(object sender, System.EventArgs e) {
			DialogResult dr = MessageBox.Show(this, RS.DELETE_RECORD, RS.DELETE_RECORD_CAPTION, 
				MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			if (dr == DialogResult.Yes) {
				cancelHandlers = true;

                //Luu vet (Deleted)
                try
                {
                    SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "insert into Tienmat_Deleted select * from TienMat " +
                                                                                "where sochungtu = '" + txtSoChungTu.Text + "'");
                }
                catch { };

				bmb.RemoveAt(bmb.Position);
				ptData.update();
				cancelHandlers = false;
				bmb_PositionChanged(bmb, e);
			}
		}

		private void cmdPrint_Click(object sender, System.EventArgs e) {
            try
            {
         
                cmdPrint.Enabled = false;
                
                //Load report
                ReportDocument rpt = new ReportDocument();
                rpt.Load(Application.StartupPath + "\\Report\\rpt_TienMat_PhieuThu_ThuLe.rpt");
                
                //Set connection
                PublicFunction.SetDBLogonForReport(rpt);

                //Set parameter
                PublicFunction.SetParameter(rpt,"@Sochungtu", txtSoChungTu.Text);
                PublicFunction.SetParameter(rpt,"pBangchu", ReportUtilities.ReportUtilities.g_Trans_VietNam(Double.Parse(txtSoTienThucThu.Text), "đồng", true));
                PublicFunction.SetParameter(rpt,"pNguoiLapBieu", GlobalVariable.WSInfo.UserName);
                PublicFunction.SetParameter(rpt,"pThuquy", GlobalVariable.WSInfo["Sys.UserName.Thuquy"]);
                PublicFunction.SetParameter(rpt,"pKetoantruong", GlobalVariable.WSInfo["Sys.UserName.KetoanTruong"]);
                PublicFunction.SetParameter(rpt,"pGiamDoc", GlobalVariable.WSInfo["Sys.UserName.Giamdoc"]);

                //View report
                frmPrintPreview frmPP = new frmPrintPreview(rpt);
                frmPP.ShowDialog();
                frmPP.Dispose();

                rpt.Dispose();
                cmdPrint.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
		}


		#endregion

        private void cmdXemTK_Click(object sender, System.EventArgs e) {
            
            ep.Clear();
            showEP = false;

			if (!cmdAddNew.Enabled && cboLyDoThu.SelectedIndex == -1) {
				ep.SetError(cboLyDoThu, "Bạn vui lòng chọn lý do thu !.");
				cboLyDoThu.Focus();
				showEP = true;
				return;
			}
            
            /*
            if (!cmdAddNew.Enabled && txtSoTien.Text.Trim() == "0") {
				ep.SetError(txtSoTien, "Bạn vui lòng nhập số tiền !.");
				txtSoTien.Focus();
				showEP = true;
				return;
			}
            */
	
            //if (!cmdAddNew.Enabled && cboDonViNopTien.SelectedIndex == -1) {
            if (!cmdAddNew.Enabled &&  gridLookUpEdit_txtMaHocSinh.EditValue.ToString() == "" )
            {
				ep.SetError(gridLookUpEdit_txtMaHocSinh, "Bạn vui lòng chọn đơn vị nộp tiền !.");
				gridLookUpEdit_txtMaHocSinh.Focus();
				showEP = true;
				return;
			}

			dgridChiTietPT.Visible = !dgridChiTietPT.Visible;
			if (dgridChiTietPT.Visible) {
				//this.Height += 120;
                this.WindowState = FormWindowState.Maximized;
         	} else {
				this.Size = this.MinimumSize;
				this.WindowState = FormWindowState.Normal;
			}
		}


        bool showEP = false;

	
		
		private object this[string colName] {
            get { return ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position][colName]; }
            set { ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position][colName] = value; }
		}

		

		private void TienMatPhieuThuHocphi_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
			if (e.KeyCode == Keys.Enter) {
				this.SelectNextControl(this.ActiveControl, true, true, true, true);
			} else if (e.KeyCode == Keys.Escape) {
				this.SelectNextControl(this.ActiveControl, true, false, true, true);
			}
		}

		private void cmdMoveFirst_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Count > 0) {
				bmb.Position = 0;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMovePrevious_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Position > 0) {
				bmb.Position -= 1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMoveLast_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Count > 0) {
				bmb.Position = bmb.Count -1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMoveNext_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Position < bmb.Count -1) {
				bmb.Position += 1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void sendStatus(string msg) {
			sendStatus(msg, false);
		}

		private void picboxHelp_Click(object sender, System.EventArgs e) {
		
		}

		private void cmdNote_Click(object sender, System.EventArgs e) {
			SimpleObjectNote son = new SimpleObjectNote(GlobalVariable.WSInfo.ConnectionString,
				this.Text, GlobalVariable.WSInfo.UserID);
			son.ShowDialog(this);
		}
	
		private void sendStatus(string msg, bool error) {
			if (error) {
				lblStatus.ForeColor = Color.Red;
				lblStatus.Text = msg;
			} else {
				lblStatus.ForeColor = Color.Black;
				lblStatus.Text = msg;
			}
		}


		
        private void cboLyDoThu_Validated(object sender, EventArgs e)
        {
            if (cboLyDoThu.SelectedIndex == -1) return;
            //Neu chua co HS thi thoi
            if (gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow() == null) return;

            if (cboLyDoThu.SelectedIndex == -1)
            {
                return;
            }
            if (gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow() != null && ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["MaDoiTac"] == null)
                return;
            ep.Clear();
            showEP = false;

            string strMaKhoi = ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["MaKhoi"].ToString();
            // Gán tài khoản có mặc định cho detail
            try
            {
                if (ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT) != null)
                {
                    ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Clear();
                    bmb.EndCurrentEdit();
                }
                // Add a default row to detail
                string strSQL = "select distinct MaTaiKhoan, DienGiai, 1 as SoLuong, isnull(DonGia,0) DonGia from DM_HOCPHI_CHITIET " +
                                "where MaKhoi = '" + strMaKhoi + "' and MaTaiKhoan like '" + cboLyDoThu.SelectedValue + "%' ";
                SqlDataReader HV_DataReader = SQLHelper.ExecuteReader(GlobalVariable.WSInfo.ConnectionString, strSQL);
                txtDienGiai.Text = "Thu tiền " + cboLyDoThu.Text + " của " + gridLookUpEdit_txtMaHocSinh.Text + " lớp " + ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["MaLop"].ToString();

                while (HV_DataReader.Read())
                {
                    try
                    {
                        DataRow dr = ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).NewRow();
                        dr["SoChungTu"] = txtSoChungTu.Text;
                        dr["TaikhoanCo"] = HV_DataReader["MaTaiKhoan"];
                        dr["MaTieukhoanCo1"] = gridLookUpEdit_txtMaHocSinh.EditValue;
                        dr["DonGia"] = HV_DataReader["DonGia"];
                        decimal SoTien = Convert.ToDecimal(HV_DataReader["SoLuong"]) * Convert.ToDecimal(HV_DataReader["DonGia"]);
                        dr["SoTien"] = SoTien;
                        dr["DienGiaiChiTiet"] = HV_DataReader["DienGiai"];
                        ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Rows.Add(dr);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                txtSoTien.Text = Convert.ToDecimal(gridColumn_ThanhTien.SummaryItem.SummaryValue).ToString("N0");
                txtSoTienThucThu.Text = txtSoTien.Text;
                
                txtMaHocPhi.Text = "B01";  //Thu bo sung
            }
            catch { }
        }

        
        protected CNCSoft.EData.VoucherNoGenerator vg;

        
        private void cmdAddNew_Click_1(object sender, EventArgs e)
        {
            lstAddnew.Visible = true;
            lstAddnew.Focus();
        }


        string strPrefixPhieuThuHocPhi;

        private void lstAddnew_SelectedIndexChanged(object sender, EventArgs e)
        {
            //MessageBox.Show(lstAddnew.SelectedValue.ToString());
            if (!lstAddnew.Visible) return;

            cancelHandlers = true;

            strPrefixPhieuThuHocPhi = lstAddnew.SelectedValue.ToString();
            string strTaiKhoanMacDinh = ((DataTable)lstAddnew.DataSource).Rows[lstAddnew.SelectedIndex]["SoTaiKhoan"].ToString();

            // Tao moi
            try
            {
                ptData.TaiKhoanMacDinh = strTaiKhoanMacDinh;
                if (ptData.createNewRow(strPrefixPhieuThuHocPhi))
                {
                    bmb.Position = bmb.Count - 1;
                    ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position]["MaLoaiChungTu"] = strPrefixPhieuThuHocPhi;
                    setEditMode(true);
                    cboLop.Focus();
                }
                cancelHandlers = false;
                bmb_PositionChanged(bmb, e);
                sendStatus("Đang trong trạng thái thêm mới...", false);
            
            }
            catch { }

            lstAddnew.Visible = false;
        }

        
        private void txtSoTienDiscount_TextChanged(object sender, EventArgs e)
        {

        }

        private void cboNganHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboNganHang.SelectedIndex == -1) return;
            try
            {
                for (int i = 0; i < ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length; i++)
                    ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[i]["MaTieuKhoanNo1"] = cboNganHang.SelectedValue;

                //ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT_CT).Rows[i]["MaTieuKhoanNo1"] = cboNganHang.SelectedValue;
            }
            catch { }
        }

        
        
        private void gridLookUpEdit_txtMaHocSinh_Validated(object sender, EventArgs e)
        {
          
        }

        
        private void cboLop_SelectedIndexChanged(object sender, EventArgs e)
        {

            try
            {
                if (cboLop.SelectedIndex == -1) return;
                gridLookUpEdit_txtMaHocSinhView.ActiveFilterString = "MaLop = '" + cboLop.SelectedValue + "'";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        
        
        
        private void txtMaNienHoc_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (txtMaNienHoc.Text == "") return;

                cboLop.SelectedValue = "";

                DataTable dt = new DataTable();
                SQLHelper.Fill(dt, GlobalVariable.WSInfo.ConnectionString, "SELECT * FROM DM_LOP WHERE MaNienHoc = '" + txtMaNienHoc.Text + "' AND MaCoSo = '" + txtMaCoSo.Text + "' Order by MaKhoi, STT");

                cboLop.DataSource = dt;
                cboLop.DisplayMember = "TenLop";
                cboLop.ValueMember = "MaLop";
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }

        private void txtThangHocPhi_TextChanged(object sender, EventArgs e)
        {

        }

        private void lstAddnew_Leave(object sender, EventArgs e)
        {
            lstAddnew.Visible = false;
        }

        private void txtSoInvoice_Validating(object sender, CancelEventArgs e)
        {
            /*
            //cancelHandlers = true;

            if (txtSoInvoice.EditValue.ToString() == "") return;

            // Gán cac detail da dinh trong KH
            try
            {
                //ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT).Rows[bmb.Position]["TongTien"] = 0;

                // Add a default row to detail
                SqlDataReader HV_DataReader = SQLHelper.ExecuteReader(GlobalVariable.WSInfo.ConnectionString,
                                                    "SELECT SoChungTu, TaiKhoanCO, MaTieukhoanCo1, DienGiaiChiTiet, SoLuong, DonGia, SoTien, SoTienMienGiam, TaiKhoanNO, MaTieukhoanNo1 " +
                                                    "FROM TIENMAT_CHITIET  " +
                                                    "WHERE  SoTien <> 0 and SoChungTu = '" + txtSoInvoice.EditValue + "'");
                
                if (ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT_CT) != null)
                    ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT_CT).Clear();
                
                while (HV_DataReader.Read())
                {
                    try
                    {
                        DataRow dr = ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT_CT).NewRow();
                        dr["SoChungTu"] = txtSoChungTu.Text ;
                        dr["TaikhoanCo"] = HV_DataReader["TaiKhoanCO"];
                        dr["MaTieukhoanCo1"] = HV_DataReader["MaTieukhoanNo1"];
                        dr["SoLuong"] = HV_DataReader["SoLuong"];
                        dr["DonGia"] = HV_DataReader["DonGia"];
                        dr["DienGiaiChiTiet"] = HV_DataReader["DienGiaiChiTiet"];
                        //dr["TaiKhoanNO"] = HV_DataReader["TaiKhoanNO"];
                        //dr["MaTieukhoanCo1"] = HV_DataReader["MaTieukhoanCo1"];

                        ptData.getTable(TienMatPhieuThuHocphiData.TL.TienMatPT_CT).Rows.Add(dr);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                try
                {
                    string strDienGiaiKeHoach = (SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT DienGiai FROM TIENMAT WHERE SoChungTu = '" + txtSoInvoice.Text + "'")).ToString();
                    txtDienGiai.Text = "Thu học phí " + strDienGiaiKeHoach + " của " + gridLookUpEdit_txtMaHocSinh.Text + " lớp " + ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["MaLop"].ToString();

                    //Tinh tong tien
                    cancelHandlers = true;
                    //txtSoTien.Text = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT sum(SoTien) FROM TIENMAT_CHITIET WHERE SoChungTu = '" + txtSoInvoice.Text + "'").ToString();
                    object obSumSoTien = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT sum(SoTien) FROM TIENMAT_CHITIET WHERE SoChungTu = '" + txtSoInvoice.Text + "'");
                    if (obSumSoTien != DBNull.Value)
                        this["TongTien"] = Convert.ToDouble(obSumSoTien);
                    //txtSoTienThucThu.Text = txtSoTien.Text;
                    //this["ThucThu"] = this["TongTien"];
                    cancelHandlers = false;
                }
                catch (Exception ex) 
                {
                    MessageBox.Show(ex.Message);
                }

                bmb.EndCurrentEdit();
                bmb_PositionChanged(bmb, e);
                
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            cancelHandlers = false;
            */
        }

        
        private void txtMaCoSo_TextChanged(object sender, EventArgs e)
        {
            txtMaNienHoc_TextChanged(sender, null);
        }

        private void gridLookUpEdit_txtMaHocSinh_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                if (gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow() == null) return;
                if (gridLookUpEdit_txtMaHocSinh.EditValue.ToString() == "") return;

                string strHoTenNguoiNopTien = ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["TenDoiTac"].ToString();
                string strDiaChi = ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["DiaChi"].ToString();
                string strMaCheDo = ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["MaCheDo"].ToString();
                string strMaKhoi = ((DataRowView)gridLookUpEdit_txtMaHocSinh.GetSelectedDataRow())["MaKhoi"].ToString();
    
                txtDiaChi.Text = strDiaChi;
                txtHoTenNguoiNopTien.Text = strHoTenNguoiNopTien;
                txtMaCheDo.Text = strMaCheDo;
                
                //Ly do thu (dung de dinh khoan)
                DataTable dt = new DataTable();

                string strSQL = "select * from DM_TAIKHOAN where MaTaiKhoan like '5113__'";
                                
                SQLHelper.Fill(dt, GlobalVariable.WSInfo.ConnectionString, strSQL); 

                this.cboLyDoThu.DataSource = dt;
                cboLyDoThu.DisplayMember = "TenTaiKhoanVN";
                cboLyDoThu.ValueMember = "MaTaiKhoan";
                //cboLyDoThu.SelectedIndex = -1;
                
                //bmb.EndCurrentEdit();
                //bmb_PositionChanged(bmb, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void gridView2_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Value != null && ((e.Column.FieldName.ToUpper() == "SOLUONG") || (e.Column.FieldName.ToUpper() == "DONGIA")))
                if (ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Rows[e.RowHandle]["SoLuong"] != DBNull.Value && ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Rows[e.RowHandle]["DonGia"] != DBNull.Value)
                    ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Rows[e.RowHandle]["SoTien"] =
                                                                    Convert.ToDecimal(ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Rows[e.RowHandle]["SoLuong"])
                                                                    * Convert.ToDecimal(ptData.getTable(TienMatPhieuThuLeData.TL.TienMatPT_CT).Rows[e.RowHandle]["DonGia"]);
        }

        private void gridView2_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            gridView2.RefreshData();
            txtSoTien.Text = Convert.ToDecimal(gridColumn_ThanhTien.SummaryItem.SummaryValue).ToString("N0");
            txtSoTienThucThu.Text = txtSoTien.Text;
        }


        private void TinhToanTien()
        {
            try
            {
                decimal dSoTienPhaiThu = txtSoTien.Text == "" ? 0 : Convert.ToDecimal(txtSoTien.Text);
                decimal dSoTienThucThu = txtSoTienThucThu.Text == "" ? 0 : Convert.ToDecimal(txtSoTienThucThu.Text);
                decimal dSoDuThangTruoc = txtSoDuThangTruoc.Text == "" ? 0 : Convert.ToDecimal(txtSoDuThangTruoc.Text);
                if (dSoTienPhaiThu != 0 || dSoTienThucThu != 0)
                    txtSoDuThangNay.Text = Convert.ToDecimal(dSoDuThangTruoc + dSoTienThucThu - dSoTienPhaiThu).ToString("N0");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void txtSoTienThucThu_Validated(object sender, EventArgs e)
        {
            TinhToanTien();
        }

        private void txtSoDuThangTruoc_Validated(object sender, EventArgs e)
        {
            TinhToanTien();
        }

        private void cboLyDoThu_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
       
	}
}